package com.example.springboot.context;

import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.context.annotation.Configuration;

/**
 * ApplicationRunner与CommandLineRunner差不多，就是拿到的参数不一样
 * <p> 拿到 ApplicationArguments 对象，支持更方便的参数解析
 * <p>
 *
 * @author Zhang.Z
 * @version 2025-09-21
 * @see Test13CommandLineRunner
 */
@Configuration
public class Test14ApplicationRunner implements ApplicationRunner {

    /**
     * java -jar app.jar arg1 arg2 --spring.profiles.active=dev
     *
     * <p>  args.getNonOptionArgs() :   [arg1, arg2]
     * <p>  args.getOptionNames():      [spring.profiles.active]
     * <p>  args.getOptionValues("spring.profiles.active"):  [dev]
     */
    @Override
    public void run(ApplicationArguments args) throws Exception {

        System.out.println("test14 application  runner");
    }
}
